<?php

class UserRegistration{

	private $daten;
	private $error;

	public function __construct($match){
		$this->daten = $match;
	}

	public function getWort(RainTPL $design){
	    $this->design = $design;
	    
		$this->design->assign ('js',"jsRegistration");
		$this->design->assign ('css',"registration");
		
		if($this->design->post->gfw_password)
		{			
		    if ( $this->design->post->gfw_password && $this->design->post->gfw_bday && FunctionClass::check_email_address($this->design->post->gfw_email))
			{
				$Bday = $this->design->post->gfw_bday;

				if ($this->design->post->gfw_sex == 1)
				{
					$sex = 'w';
				}
				elseif($this->design->post->gfw_sex == 2)
				{
					$sex = 'm';
				}
				else
				{
					$this->error = ERROR_SEX;
				}
				$code = FunctionClass::CreateKey();
                $Model_Db_User = new Db_User();
                
				if ($Model_Db_User->CreateUser($this->design->post->gfw_username,$this->design->post->gfw_email,$this->design->post->gfw_password,$Bday,$sex,$code))
				{
					$body = 'Um Ihren Account zu Aktiviernen Müssen Sie hier auf den Link Klicken <a href="http://localhost/test/akiv/'.$code.'">Klick Mich</a>';
					try{
						//$this->System->request->SendEmail($this->System->request->Post('GFW_email'),'Account Aktivierung',$body);
					}catch(Exception $e){
						$e->getMessage();
						exit;
					}
					$this->design->assign ( 'info','Ihre anmeldung war erfolgreich im ihrern Account jetzt frei zu schalten m�sseb Sie....');
				}
				else
				{
					$this->error = ERROR_EMAIL_IN_SYSTEM;
				}
			}
			else
			{
				$this->error = ERROR_FORGET;
			}
		}
		if (! $this->error == "")
		{
			$this->design->assign ( 'Error', $this->error );
		}
		
	    if( $cache = $this->design->cache( $this->design->ln.'/User/registration', $expire_time = 0 ) )
		 {
		 	echo $cache;
		 }
		 else
		 {
		 	$this->design->draw( $this->design->ln.'/User/registration' );
		 }
	}

}
?>